﻿using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Castle.Windsor;
using MM.Web.Controllers;

namespace MM.Bootstrapper
{
    public class WindsorControllerFactory : DefaultControllerFactory
    {
        private IWindsorContainer container;

        public WindsorControllerFactory(IWindsorContainer container) {
            
            this.container = container;
        }

        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {

            if (controllerType != null)
            {
                
                return (IController)container.Resolve(controllerType);

            }


            return base.GetControllerInstance(requestContext, controllerType);
        }

        
    }
}
